<?php  
namespace Admin\Model;
use Think\Model;
class CatModel extends Model{
	public function gettree($p=0,$lv=0)
	{
     $tree=array();
     foreach ($this->cache(true)->select() as $k => $v) {
     	if($v['parent_id'] == $p )
     	{
     		$v['lv']=$lv;
     		$tree[] = $v;
           $tree = array_merge($tree,$this->gettree($v['cat_id'],$lv+1));
     	}
      }
      return $tree;
	}
}